import Vue from 'vue';
import VueRouter from 'vue-router';

import {
    Home,
    First
} from './pages';

Vue.use(VueRouter);

const routes = [
    {
        path:'/',
        redirect:'/home'
    },
    {
        path:'/home',
        component:Home,
        name:'home',
        children:[
            {
                path:'first',
                component:First,
                name:'first'
            }
        ]
    }
];

export const router = new VueRouter({
   routes
});
router.beforeEach((to, from, next) => {
    Vue.prototype.$loading();
    next();
});
router.afterEach(route => {
    Vue.prototype.$loading.close();
});